#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;

class Solution {
public:
	string addStrings(string num1, string num2) {

		int next = 0;
		int end1 = num1.size() - 1;
		int end2 = num2.size() - 1;
		string retstr;
		while (end1 >= 0 || end2 >= 0)
		{
			int a = 0;
			int b = 0;
			if (end1 >= 0)
				a = num1[end1] - '0';
			if (end2 >= 0)
				b = num2[end2] - '0';

			int sum = a + b + next;
			char c = sum % 10 + '0';
			next = sum / 10;

			retstr.insert(0, 1, c);

			end1--;
			end2--;

		}

		if (next == 1)
			retstr.insert(0, 1, '1');

		return retstr;

	}


	int main()
	{

		string s1 = addStrings("11", "123");
		cout << s1;

		return 0;
	}
};
